package com.study.spmongodb.wwj.thread.char06;

/**
 * @author MI
 * @version 1.0
 * @date 2020/12/6 10:51
 */
public class ThreadCloseGracaeful {
    private static class Worker extends Thread {
        private volatile boolean start = true;

        @Override
        public void run() {
            while (start) {
            }
        }

        public void shutdown() {
            this.start = false;
        }
    }

    public static void main(String[] args) throws InterruptedException {
        final Worker worker = new Worker();
        worker.start();
        Thread.sleep(1000);
        worker.shutdown();
    }
}
